﻿using OpenfireAPI;
using QD.WX.Utill;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QDChat
{
    public class SDK
    {
        public  void Demo()
        {
            var url = "http://192.168.1.162";

            var auth = new OpenfireAPI.util.OpenfireAuthenticator("admin", "admin");
            OpenfireApiClient client = new OpenfireApiClient(url, 9090, auth, true);

            //Request All available users
            var ues = client.getUsers();

            //Get specific user by username
            var ue = client.getUser("test02");

            //Create new user
            bool result = client.createUser(new OpenfireAPI.entity.UserEntity { username = "test", email = "test@gmail.com", name = "test", password = "ZAQ!2wsx" });

        }

        public void Demo2()
        {
            var url = "http://192.168.1.162:9090/plugins/restapi/v1/users/test01";
            var html = "";
            WebRequestHelper.Request(url, "", out html);
            Echo(html);
        }

        void Echo(object msg)
        {
            Console.WriteLine(msg);
        }
    }
}
